package com.itheima.springbootinit;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author 蒋银辉
 * @version 1.0
 */
@RestController
public class HelloController {
    @Autowired
    private Person person;
    @Value("${person.name}")
    private String name;

    @Value("${person.age}")
    private String age;

    @Autowired
    private Environment env;

    @RequestMapping("/hello")
    public String hello(){
        return "hello SpringBoot";
    }
    @RequestMapping("/hello2")
    public String hello2(){
        System.out.println(name);
        System.out.println(age);
        System.out.println("----------------");
        System.out.println(env.getProperty("address[0]"));
        System.out.println("----------------");
        System.out.println(person);
        String[] address = person.getAddress();
        for (String s: address) {
            System.out.println(s);
        }
        return "hello SpringBoot";
    }
}